package mongo.db.clients.firsts;

import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;

import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.MongoClient;
import com.mongodb.ServerAddress;

public class GenForTimeSlice {

	/**
	 * @param args
	 */

	private static DB db;
	private static MongoClient client;
	static List<ServerAddress> seeds;

	public static void main(String[] args) throws UnknownHostException, InterruptedException {

		seeds = new ArrayList<ServerAddress>();
		seeds.add(new ServerAddress("SS59-MAA", 27021));
		seeds.add(new ServerAddress("SS59-MAA", 27022));

		client = new MongoClient(seeds);
		db = client.getDB("netflow");

		Random rn = new Random();
		DBCollection flows = db.getCollection("timegen");

		for (int i = 0; i < 30; i++) {
			Date now = new Date();
			BasicDBObject dbo = new BasicDBObject("count", i).append("time", now);
			flows.insert(dbo);
			// System.out.println(JSON.parse(dbo.toString()));
			System.out.println("inserted count : " + i + " time as is : " + now + " long : " + now.getTime());
			Thread.sleep(rn.nextInt(5) * 1000);
		}

	}

}
